# -*- coding:utf-8 -*-
"""
@author: 
@file: chart.py
@time: 2023/12/17 16:19
@desc: 数据图表
"""
from django.shortcuts import render
from django.http import JsonResponse


def chart_list(request):
    """ 数据可视化 """
    return render(request, 'chart_list.html')


def chart_line(reqeust):
    legend = ['柳州市', '南宁市']
    series_list = [
        {
            'name': '吴峰',
            'type': 'line',
            'stack': 'Total',
            'data': [120, 132, 101, 134, 90, 230, 210]
        },
        {
            'name': '吴顺',
            'type': 'line',
            'stack': 'Total',
            'data': [220, 182, 191, 234, 290, 330, 310]
        }
    ]
    x_axis = ['第一季度', '第二季度', '第三季度', '第四季度']

    result = {
        "status": True,
        "data": {
            'legend': legend,
            'series_list': series_list,
            'x_axis': x_axis
        }
    }
    return JsonResponse(result)

def chart_bar(request):
    """ 构造柱状图的数据 """
    pass


def chart_pic(reqeust):
    """ 构造饼图的数据 """
    db_data_list = [
        {'value': 1048, 'name': 'IT部'},
        {'value': 735, 'name': '财务部'},
        {'value': 580, 'name': '新媒体'},
        {'value': 484, 'name': '业务部'},
        {'value': 300, 'name': '直播部'}
    ]
    result = {
        "status": True,
        "data": db_data_list,
    }

    return JsonResponse(result)


def highcharts(request):
    return render(request,'highcharts.html')
